import React, { Component } from 'react'
import Grid from 'components/grid/Grid'
import "./HotCate.style.scss"
import { get } from 'api/http'
import {withRouter} from 'react-router-dom'

 class HotCate extends Component {

  constructor() {
    super();
    this.state = {
      datalist: []
    }
  }

  render() {
    return (
      <div className="hotCatiner">
        <h2>
          热门分类
        </h2>
        <Grid column={4} list={this.state.datalist} hasMore={true}
          itemClick={()=>{
            // /list
            this.props.history.push('/list')
          }}
          renderTitle={({item}) => {
            return <span>{item.title}</span>
          }}
        ></Grid>
      </div>
    )
  }

  async componentDidMount() {
    let rs = await get('/api/hotcate')
    console.log(rs);
    this.setState({
      datalist: rs.data.list
    })
  }
}

export default withRouter(HotCate)